/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jard.webshop.jsfbeans;

import jard.webshop.management.PreferencesManagement;
import jard.webshop.nbp.SitePref;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author CJP
 */
@ManagedBean(name = "prefBean")
public class PreferencesBackingBean {

    private SitePref pref = null;

    /** Creates a new instance of PreferencesBackingBean */
    public PreferencesBackingBean() {
        System.out.println("PreferencesBackingBean Constructor");
        PreferencesManagement prm = PreferencesManagement.getInstance();
        List<SitePref> prefs = prm.getPreferences();
        pref = prefs.get(0);
        System.out.println("got preference from db: " + pref);

    }

    public String savePreferences() {
        System.out.println("Saving preferences as: " + this.pref + "");
        PreferencesManagement prm = PreferencesManagement.getInstance();
        prm.savePreferences(this.pref);
        return "main";
    }

    public String getWebshopname() {
        System.out.println("Return webshopname " + pref.getWebshopname());
        return pref.getWebshopname();
    }

    public void setWebshopname(String webshopname) {
        pref.setWebshopname(webshopname);
    }

    public String getDescription() {
        return pref.getDescription();
    }

    public void setDescription(String description) {
        pref.setDescription(description);
    }

    public String getKeywords() {
        return pref.getKeywords();
    }

    public void setKeywords(String keywords) {
        pref.setKeywords(keywords);
    }

    public String getAuthor() {
        return pref.getAuthor();
    }

    public void setAuthor(String author) {
        pref.setAuthor(author);
    }

    public Boolean getShowAlertMessage() {
        return pref.getShowAlertMessage();
    }

    public void setShowAlertMessage(Boolean showAlertMessage) {
        pref.setShowAlertMessage(showAlertMessage);
    }

    public String getAlertMessage() {
        return pref.getAlertMessage();
    }

    public void setAlertMessage(String alertMessage) {
        pref.setAlertMessage(alertMessage);
    }

    public boolean getSiteOffline() {
        return pref.getSiteOffline();
    }

    public void setSiteOffline(Boolean siteOffline) {
        pref.setSiteOffline(siteOffline);
    }

    public String getOfflineMessage() {
        return pref.getOfflineMessage();
    }

    public void setOfflineMessage(String offlineMessage) {
        pref.setOfflineMessage(offlineMessage);
    }
}
